var still="still";
var timelapse="timelapse";
var group="group";

var NS=0;
var IE=0;

function cls( )
{
    print(" ")
    top.frames[2].document.open( );
    top.frames[2].document.close( );


}

function printf(mssg)
{
	var i;
	var theLen = printf.arguments.length;

	for( i = 0 ; i< theLen ; i++)
		top.frames[2].document.writeln(printf.arguments[i]);

		top.frames[2].document.writeln('<br>');

}

function print(mssg)
{
	var i;
	var theLen = print.arguments.length;

	for( i = 0 ; i< theLen ; i++)
		top.frames[2].document.writeln(print.arguments[i]);
}




function selectCamera(sel)
{
// NOTE:  no switch before Netscape 4.0

		if (sel.selectedIndex == 0){
		theCamera="Kodak DC220";
		paramTagArray=dc220;
		fileTagArray = f260;
		}
		else if( sel.selectedIndex == 1){
		
		theCamera="Kodak DC260";
		paramTagArray=dc260;
		fileTagArray=f260;
		}
		else if ( sel.selectedIndex == 2){
		theCamera="Minolta EX1500";
		paramTagArray=minolta;
		fileTagArray=f260;
		}
		else if ( sel.selectedIndex == 3){
		theCamera="Unity";
		paramTagArray=unity;
		fileTagArray=funity;
		}

		else if (sel.selectedIndex == 4){
		alert("function selectCamera in initializeFunction.js");
		}



}

function flashpoint()
{

	printf('# (c) 1998 FlashPoint Technology, Inc. Digita and the Digita Logo are ');
	printf('# trademarks of FlashPoint Technology, Inc. ');

	printf('# This script may be reused in whole or in part as long as the modified ');
	printf('# script includes the following notice:  ');
	printf('# "Portions of this script are copyrighted by FlashPoint Technology Inc." ');
	printf(' ');

}


function selectCameraQA(sel)
{
// NOTE:  no switch before Netscape 4.0

		if (sel.selectedIndex == 0){
		theCamera="Kodak DC220";
		paramTagArray=dc220QA;
		fileTagArray = f260;
		}
		else if( sel.selectedIndex == 1){
		
		theCamera="Kodak DC260";
		paramTagArray=dc260QA;
		fileTagArray=f260;
		}
		else if ( sel.selectedIndex == 2){
		theCamera="Minolta EX1500";
		paramTagArray=minoltaQA;
		fileTagArray=f260;
		}
		else if ( sel.selectedIndex == 3){
		theCamera="Unity";
		paramTagArray=unity;
		fileTagArray=funity;
		}


		else if (sel.selectedIndex == 4){
		alert("function selectCamera in initializeFunction.js");
		}



}





function writef(mssg)
{
	var i;
	var theLen = writef.arguments.length;
        top.frames[1].document.writeln('WriteLine(fd,"');
    
	for( i = 0 ; i< theLen ; i++)
		top.frames[1].document.writeln(writef.arguments[i]);

        top.frames[2].document.writeln('");');
	top.frames[2].document.writeln('<br>');

}

function write(mssg)
{
	var i;
	var theLen = write.arguments.length;

	for( i = 0 ; i< theLen ; i++)
		top.frames[2].document.writeln(write.arguments[i]);

       top.frames[2].document.writeln('");');



}
		
		
function PP(mssg)
{
	var i;
	var theLen = PP.arguments.length;

	for( i = 0 ; i< theLen ; i++)
		top.frames[2].document.writeln(PP.arguments[i]);

		top.frames[2].document.writeln('<br>');

}

function writeMenu(name, menu,label)
{
	// all these will have variables in the second slot
	printf(' ');
	
	printf('# **** ',theCamera,' ****',theCamera,' ****');
	if( label.indexOf("Capa") != -1 ){
	printf('# NOTE: This script examines the camera capabilities');
	printf('# and is best run on the ',theCamera,'.' );

	}
	else if( label.indexOf("StartCapture") != -1 ){
	printf('# NOTE: This script should   run properly on all Digita cameras');
	}
	else if( label.indexOf("File") != -1 ){
	printf('# NOTE: This script should   run properly on all Digita cameras');
	}
	else if( label.indexOf("Storage") != -1 ){
	printf('# NOTE: This script should   run properly on all Digita cameras');
	} 
	else if( label.indexOf("J") == 1 ){
	printf('# NOTE: This script attempts to display Japanese characters');
	} 
 
	else{
	printf('# NOTE: Although this script runs on all Digita cameras');
	printf('# there are a few camera tag parameters which are unique to');
	printf('# each camera.  This script is for the ',theCamera );	
	}
	
	printf(' ');
	
	printf('name', name );
	printf('mode ' , '0' );
	printf('menu ',menu);
	printf('label ' ,label);

}


function writeVariables()
{
	printf(' ');
	printf('# *** DECLARE VARIABLES *** ');
	printf('declare u: fd,status,openStatus,findex' );
	printf('declare u: status1,status2,status3' );
	printf('declare u: choice,choice1,choice2,choice3' );

	printf('declare s: param ' );
	printf('declare u: uvar,uvar1,uvar2,uvar3,uvar4,uvar5' );
	printf('declare i: ivar,ivar1,ivar2,ivar3,ivar4,ivar5' );
	printf('declare s: svar,svar1,svar2,svar3,svar4,svar5' );
	printf('declare n: nvar,nvar1,nvar2,nvar3,nvar4,nvar5' );
	printf('declare b: bvar,bvar1,bvar2,bvar3,bvar4,bvar5' );
	printf('declare f: fvar,fvar1,fvar2,fvar3,fvar4,fvar5' );
	
	printf('declare s: date,time,sdate,stime' );
	printf('declare s: outFile,theType,sDesc' );
	printf('declare i: count,icount' );
	printf('declare i: min,max,default');
	printf('declare u: umin,umax,udefault');
	printf('declare b: bmin,bmax,bdefault');
	printf('declare s: smin,smax,sdefault');
	printf('declare i: imin,imax,idefault');
	printf('declare u: ucount, uValue ,uIndex');
	printf('declare s: sDefault, sIndex');
 	printf('declare s: sValue');

 	printf('declare b: bcount,  bvalue ');
	printf('declare b: system,capture,vendor ');
	printf('');
	
}



function declareVariables(theName,count)
{
	var i=0;
	
	while(i <=  count )
	{
	    if(i%6==0){	
	     printf(' ');    
	     print('declare s: ',theName + i  );
	     i++;
	     }
	    print(',' , theName + i );
	
	   i++;
	
	}


}

function writeFileOpen()
{

	printf(' openStatus = FileOpen( 2, outFile , 1, fd )' );
	printf(' if openStatus !=0 ');
	printf('    DisplayLine( "Error opening a file" )' );
	printf('    Wait( 3000 )' );
	printf('    exitscript' );
	printf(' end' );

	printf(' openStatus = WriteLine( fd, " *** Filename: ", outFile, " *** " )' );

	printf(' if openStatus != 0' );
	printf('    DisplayLine( "Error writing to a file")' );
	printf('    Wait(3000)' );
	printf('    exitscript' );
	printf(' end' );
	printf(' ');

	printf('GetProductInfo("ptid",svar)');
	printf('WriteLine( fd, " *** ", svar, " *** " )' );
	printf('WriteLine( fd, " " )' );
	printf('WriteLine( fd, " " )' );

	printf(' ');

}


function writeFileClose()
{
	printf(' ' );
	printf('#**** CLOSE FILE ****');
	printf(' openStatus = FileClose( fd )' );
	printf(' if openStatus !=0 ');
	printf('    DisplayLine( "Error closing a file" )' );
	printf('    Wait( 3000 )' );
	printf('    exitscript' );
	printf(' end' );

}

/*
 * shuffle an array
 *
 */
function shuffle(a)
{

	var r,temp;
	r=0;
	var len;
	len = a.length;

	for( i=0; i < len ; i++)
	{
			r = Math.floor( (Math.random() * 100) % len );
			r = r% len;			// again?
			temp = a[i];
			a[i] = a[r];
			a[r] = temp;
			
			if( r > a.length) alert("too long");

	}


}


/*
 * produce a random number between low and high
 */
function randomlowhigh(low,high)
{

	var max;
	
	// normalize
	max=high-low;
	
	r = Math.floor( (Math.random() * (high-low)*10) % max );
	r = r% max;			// again?
	
	r += low;
	
	return r;

}

function randomFNumber(maximum,digits)
{
		var len = randomFNumber.arguments.length;

		theNumber = Math.random();
		theNumber = theNumber*maximum;
		
		// handle a integer.mantissa number
		theString = "" + theNumber;
		theString = theString.substring(0, theString.indexOf(".") + 1 + digits);
		
		// an integer.mantissa (>1) number
		if( maximum > 1){
		
		// add a negative sign if requested
		if( len>=3) theString="-"+theNumber;
		
		returnNumber = theString;
		
		}
		
		// handle only a mantissa (<1) number
		if( maximum <= 1){
		
		// positive number
		if( (len < 3) && (theNumber>=.1) ) returnNumber = "0"+theString;
		if( (len < 3 ) && (theNumber<.1) ) returnNumber = ""+theString;

		// negative number				
		if( (len >= 3) && (theNumber>=.1) ) returnNumber = "-0"+theString;
		if( (len >= 3) && (theNumber<.1) ) returnNumber = "-"+theString;
	
		}
		
		anumber=1.0;
		anumber = anumber * returnNumber;// make sure its a number not a string
		
		return anumber;

}

/* reduce output to fewer digits */
function FixedDigits(theNumber,digits)
{

		theString = "" + theNumber;
//		if(theNumber<0) theString="-" + theNumber;
		
		theString = theString.substring(0, theString.indexOf(".") + 1 + digits);
//		if(theNumber<0) theString="-" + theString;
		
		
		return 1 * theString;

}

/* change number to Digita Fixed Point Display  */
function Dfixed(theNumber)
{
		
		digits = 0;
		if(Dfixed.arguments.length>=2) {
		 digits = 1*Dfixed.arguments[1];
//		 printf("digits = ",digits);
		}
					
	
	
		return FixedDigits(65536 * theNumber,digits);

}


function randomIntNumber(maximum)
{

		theNumber = Math.random();
		theNumber = theNumber*maximum;
				
		theString = ""+ theNumber;
		theString = theString.substring(0, theString.indexOf(".") );
		
		if( theString == "") theString = "0";
		
		returnNumber = theString;

		anumber=1;
		anumber = anumber* returnNumber;    // make sure its a number not a string
		return anumber;

}

function itoa(theVar, digits)
{

/* CONVERT NUMBER TO STRING WITH 
  NUMBER REDUCED DOWN TO 'digit's in mantissa
*/

	theString = " " + theVar;
		
	if( theVar <1.0 && theVar >=0.1)    // if theVar = (0 ,.99999)  add a zero
			theString = "0"+theVar;
	
	if( theVar >-1.0 && theVar <-0.0999){
			theVar = 0 - theVar;
			theString = "-0" + theVar;		
	}
	
	if ( theString.indexOf(".") == -1) {
		theString = theString+ ".0000";
	
	}else				
	theString = theString.substring(0, theString.indexOf(".") + 1 + digits);


	return theString;



}

